using I2.Loc;
using UnityEngine;

public class SceneLoadBar : MonoBehaviour
{
	private const int tutorialMaxCount = 3;

	private const string tutorialSaveKey = "WatchTutorialScreen";

	public static float maxCountSectors;

	public UISprite sprite;

	public UITexture background;

	public UILabel hintLable;

	public GameObject hintContainer;

	public string normalTextureName;

	public string tuorialTextureName;

	public static bool showHalfBar = true;

	private string[] hints = new string[15]
	{
		"Lobby_to_Game_podskazki_1", "Lobby_to_Game_podskazki_2", "Lobby_to_Game_podskazki_3", "Lobby_to_Game_podskazki_4", "Lobby_to_Game_podskazki_5", "Lobby_to_Game_podskazki_6", "Lobby_to_Game_podskazki_7", "Lobby_to_Game_podskazki_8", "Lobby_to_Game_podskazki_9", "Lobby_to_Game_podskazki_10",
		"Lobby_to_Game_podskazki_11", "Lobby_to_Game_podskazki_12", "Lobby_to_Game_podskazki_13", "Lobby_to_Game_podskazki_14", "Lobby_to_Game_podskazki_15"
	};

	private bool startFlag;

	public GameObject tutorialSnowZone;

	private void Awake()
	{
		SetBackgroundTexture();
		tutorialSnowZone.SetActive(false);
		background.gameObject.SetActive(true);
		sprite.fillAmount = 0.85f;
		startFlag = false;
		sprite.gameObject.SetActive(true);
	}

	private void OnEnable()
	{
		if (!showHalfBar)
		{
			sprite.fillAmount = 0f;
		}
		if ((bool)background && (bool)hintContainer && (bool)hintLable)
		{
			if (!startFlag && showHalfBar)
			{
				sprite.fillAmount = 0.85f;
				sprite.gameObject.SetActive(true);
			}
			hintContainer.SetActive(true);
			hintLable.text = ScriptLocalization.Get("Loading_Screens/" + hints[Random.Range(0, hints.Length)]);
		}
	}

	private void OnDisable()
	{
		showHalfBar = true;
	}

	private void Update()
	{
		if (ManagerPreloadingSectors.thisScript.listFirst.Count == 0 && startFlag)
		{
			sprite.fillAmount = 0f;
			sprite.gameObject.SetActive(false);
		}
		if (ManagerPreloadingSectors.thisScript.isFirstLoading && maxCountSectors > 0f)
		{
			startFlag = true;
			sprite.fillAmount = 0.95f;
		}
	}

	private void SetBackgroundTexture()
	{
		string text = controllerLoadingGame.typeGame.ToString().ToLower();
		if (controllerLoadingGame.typeGame == TypeGame.normal)
		{
		}
		text = BCWStorage.Get<string>(settings.keyForShowLoadingSprite);
		Texture texture = Resources.Load<Texture>("TextureForPreload/loaders/" + text);
		if (texture != null && background != null)
		{
			background.mainTexture = texture;
		}
	}

	public void SetBackgroundTextureForLobby()
	{
		controllerLoadingGame.typeGame = TypeGame.normal;
		string text = BCWStorage.Get<string>(settings.keyForShowLoadingSprite);
		Texture texture = Resources.Load<Texture>("TextureForPreload/loaders/" + text);
		if (texture != null && background != null)
		{
			background.mainTexture = texture;
		}
	}

	public void SetNewImage(string nameScene)
	{
	}
}
